package task;
import java.util.Scanner;
public class TaskFirst {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        String dnaSequence = scanner.next();
        int subStringLength = scanner.nextInt();
        scanner.close();
        System.out.println(subString(dnaSequence,subStringLength));
    }

    private static String subString(String dnaSequence, int subStringLength) {
        double maxGCRatio = 0.0;
        String maxGCRatioSubstring = "";
        for (int i = 0; i <= dnaSequence.length() - subStringLength ; i++) {
            String subString =  dnaSequence.substring(i,i+subStringLength);

            double gcRatio = calculatrGCRatio(subString);
            if (gcRatio > maxGCRatio) {
                maxGCRatio = gcRatio;
                maxGCRatioSubstring = subString;
            }
        }
        return maxGCRatioSubstring;
    }

    private static double calculatrGCRatio(String subString) {
        int gcCount = 0;
        for (char c : subString.toCharArray()) {
            if (c == 'G'||c == 'C') {
                gcCount++;
            }
        }


        return (double) gcCount/subString.length();
    }
}
